package com.groupfour.attendancemanagementsystem.configuration;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 解决跨域
 * @author 唐知白
 * @Date 2022/3/19
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOriginPatterns("http://43.142.67.126:8000")
                .allowCredentials(true)
                .allowedMethods("GET","POST","DELETE","PUT","OPTIONS")
                .allowedHeaders("*")
                .maxAge(3600);
    }
    /*@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //文件磁盘图片url 映射
        //配置server虚拟路径，handler为前台访问的目录，locations为files相对应的本地路径
        registry.addResourceHandler("/tree/image/**")
                .addResourceLocations("file:/src/main/resource/static/image/");
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }*/
}
